package com.wanxi.javabean;

import java.util.Arrays;
import java.util.Scanner;

public class StudentTest {
    public static void main(String[] args) {
        Student[] students = new Student[3];

        setStudentData(students);
        System.out.println(Arrays.toString(students));

    }

    private static void setStudentData(Student[] students) {
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < students.length; i++) {
            System.out.println("请输入学生信息，格式：姓名,年龄");
//            String str = scanner.next();//张三,23
            String str = "张三,23";//张三,23
            Student student = new Student();
            student.setName(str.split(",")[0]);
            student.setAge(Integer.parseInt(str.split(",")[1]));
            students[i] = student;
        }
    }
}
